home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
cluster2.zip
/
SOURCE.ZIP
/
PB3BOXES.BU
< prev
next >
Wrap
Text File
|
1996-06-16
|
30KB
|
811 lines
'╒═══════════════════════════════════════════════════════════════════════════╕
'│ │
'│ Text Screen routines for PowerBASIC │
'│ Copyright (c) 1995 by PowerBASIC, Inc. All Rights Reserved. │
'│ │
'│ Note: These routines are written for maximum speed and will have to be │
'│ modified to prevent snow on older CGA cards. │
'│ │
'├───────────────────────────────────────────────────────────────────────────┤
'│ │
'│ LineEdit - Edit a line of text; can be longer than the edit window │
'│ LineInput - Get a line of text from the user with a specified limit │
'│ PgCopy - Copy one Text video page to another on a color screen │
'│ QATTR - Change the background attributes of a given location │
'│ QBOX - Display a text box with in a specified color │
'│ QFILL - Fill a specified location with a char and attribute │
'│ QPRINT - Quickly print a string to the screen │
'│ QPRINTC - Quickly print a centered string to the screen │
'│ QREST - Restore a saved portion of the screen │
'│ QSAVE - Save a portion of the screen │
'│ ScrollDown - Scroll a specified portion of the screen down │
'│ ScrollUp - Scroll a specified portion of the screen up │
'│ SetBlink - Change the blink bit status on EGA/VGA text screens │
'│ │
'├───────────────────────────────────────────────────────────────────────────┤
'│ │
'│ 10 June 96 -- Bud Durland │
'│ │
'│ Modified to store saved screen areas in dynamic strings; minor bug │
'│ in QATTR corrected; input routine changed for more control. │
'│ │
'│ The original routines in SCRNUNIT were written to save screen │
'│ areas inINTEGER arrays. This is OK if you are only doing one box at │
'│ a time, but is expensive in terms of memory for multiple boxes. │
'│ Using strings to save screen areas is more economical, since you can │
'│ create a string array for however many boxes you will be using, and │
'│ dynamic strings will then only consume enough memory to hold the │
'│ screen area specified. An integer array would always have to be │
'│ dimensioned for the largest possible screen area. │
'│ │
'╘═══════════════════════════════════════════════════════════════════════════╛
$COMPILE UNIT ".\SCRNUNIT.PBU"
$CODE SEG "SCRNLIB"
$CPU 8086 ' Make compatible with XT systems
$LIB ALL OFF ' Turn off all PowerBASIC libraries
$ERROR ALL OFF ' Turn off all PowerBASIC error checking
$OPTIMIZE SIZE ' Optimize for smaller code
DEFINT A-Z ' Required for all numeric functions, forces PB to not
' include floating point in UNIT (makes it smaller)
DECLARE SUB GetStrLoc() ' internal string locator in RTL
$INCLUDE ".\PB3BOXES.HDR" ' includes defs & declares for all modules.
'===========================================================================
' QSAVE - saves specified portion of a text screen in a string
'
' Row = Starting screen row of area to save
' Col = Starting screen column of area to save
' Rows = Number of rows to save (must be 1 or greater)
' Cols = Number of columns to save (must be 1 or greater)
' Where = string where data is to be saved
'
SUB QSAVE(BYVAL Row AS INTEGER, BYVAL Col AS INTEGER, _
BYVAL Rows AS INTEGER, BYVAL Cols AS INTEGER, _
Where AS STRING) LOCAL PUBLIC
DIM ScrnSeg AS INTEGER
DIM WhereMem AS DWORD
IF (pbvScrnCard AND 1) = 0 THEN
ScrnSeg = &HB800 ' color monitor
ELSE
ScrnSeg = &HB000 ' mono monitor
END IF
dLen% = (Rows * Cols) * 2 ' how much data to store?
Where = LEFT$(Where + SPACE$(dLen%),dLen%) ' make string long enough
WhereMem = STRPTR32(Where)
! push DS ; save DS for PowerBASIC
! les DI, WhereMem ; put location of array element in ES:DI
! mov AX, ScrnSeg ; put screen segment in AX
! mov DS, AX ; move to DS
! mov AX, Row ; put row in AX
! dec AX ; minus one
! mov CX, 160 ; AX =
! mul CX ; AX * 160
! mov SI, AX ; put it in SI
! mov AX, Col ; put column in AX
! dec AX ; minus one
! shl AX, 1 ; times 2
! add SI, AX ; add to SI
! mov DX, Rows ; put rows in DX
SaveRow:
! mov CX, Cols ; put number of columns in CX
! push SI ; save screen offset
! rep movsw ; copy CX words to array from screen
! pop SI ; restore screen offset
! add SI, 160 ; move to next row
! dec DX ; one less row to do
! jnz SaveRow ; if it's zero, we're done
! pop DS ; restore DS for PowerBASIC
END SUB
'===========================================================================
' QREST - Restores specified portion of a text screen from a string
'
' Row = Starting screen row of area to restore
' Col = Starting screen column of area to restore
' Rows = Number of rows to restore (must be 1 or greater)
' Cols = Number of columns to restore (must be 1 or greater)
' Where = Starting element of integer array where data is to be restored from
'
SUB QREST(BYVAL Row AS INTEGER, BYVAL Col AS INTEGER, _
BYVAL Rows AS INTEGER, BYVAL Cols AS INTEGER, _
Where AS STRING) LOCAL PUBLIC
DIM ScrnSeg AS INTEGER
DIM WhereMem AS DWORD
IF (pbvScrnCard AND 1) = 0 THEN
ScrnSeg = &HB800 ' color monitor
ELSE
ScrnSeg = &HB000 ' mono monitor
END IF
WhereMem = STRPTR32(Where) ' point to data in string
! push DS ; save DS for PowerBASIC
! lds SI, WhereMem ; put location of array in DS:SI
! mov AX, ScrnSeg ; put screen segment in AX
! mov ES, AX ; move to ES
! mov AX, Row ; put row in AX
! dec AX ; minus one
! mov CX, 160 ; AX =
! mul CX ; AX * 160
! mov DI, AX ; put it in DI
! mov AX, Col ; put column in AX
! dec AX ; minus one
! shl AX, 1 ; times 2
! add DI, AX ; add to DI
! mov DX, Rows ; put rows in DX
RestoreRow:
! mov CX, Cols ; put number of columns in CX
! push DI ; save screen offset
! rep movsw ; copy CX words to array from screen
! pop DI ; restore screen offset
! add DI, 160 ; move to next row
! dec DX ; one less row to do
! jnz RestoreRow ; if it's zero, we're done
! pop DS ; restore DS for PowerBASIC
END SUB
'===========================================================================
' QBOX - Display a box on the screen
'
' Row = Starting screen row of box
' Col = Starting screen column of box
' Rows = Number of rows for the box
' Cols = Number of columns for the box
' Attr = Color